package site.wanjiahao;

import site.wanjiahao.list.LinkedList;

public class Deque<E> {

    private final LinkedList<E> list = new LinkedList<>();

    public int size() {
        return list.size();
    }

    public boolean isEmpty() {
        return list.isEmpty();
    }

    public void clear() {
        list.clear();
    }

    public void enQueueRear(E e) {
        list.add(e);
    }

    public void enQueueFront(E e) {
        list.add(0, e);
    }

    public E deQueueRear() {
        return list.remove(list.size() - 1);
    }

    public E deQueueFront() {
        return list.remove(0);
    }

    E front() {
        return list.get(0);
    }

    E rear() {
        return list.get(list.size() - 1);
    }
}
